#pragma once
#include <string>
#include "Imagem.h"

struct PCXHeader
{
	char magic;					// always 0x0A
	char version;
	char encoding;				// indicates RLE
	char bitsPerPixel;
	unsigned short  xStart;
	unsigned short  yStart;
	unsigned short  xEnd;					// width
	unsigned short  yEnd;					// height
	unsigned short  hResolution;			// horizontal resolution
	unsigned short  vResolution;			// vertical resolution
	char palette[48];			// dummy for 256 color images
	char reserved;              // ignored
	char nColorPlanes;			// number of color planes
	unsigned short  bytesPerLine;			// bytes per scan line
	unsigned short  paletteType;			// colored or grey scale
	unsigned short  hScreenSize;			// horizontal screen size
	unsigned short  vScreenSize;			// vertical screen size
	char reserved2[54];			// reserved, always 0
};

typedef unsigned char byte;

class PCXImage
{
public:
	PCXImage( const std::string filename );
	~PCXImage( void );
private:
	struct PCXHeader m_header;
	FILE *imageFile;
	std::string m_filename;
	int palette[256];
public:
	Imagem* loadPCXImage( void );
private:
	void readHeader( void );
};

